<?php
class Login extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
        $this->load->library(array('session', 'pagination'));
        $this->load->helper(array('url', 'form', 'date'));
        $this->load->database();
    }

    function index()
    {
        $this->load->view("Backend/login");
    }

    function check_login(){
        $this->load->model("LoginModel");
        $userinfo=$this->LoginModel->get_user_info();
        if(empty($userinfo)){
            $data['error']="用户名密码不正确";
            $this->load->view("Backend/login",$data);
        }else{
            foreach($userinfo as $value){
                $wPower=$value['wPower'];
                $wName=$value['wName'];
                $workerId=$value['id'];
                $wSchool = $value["wSchool"];
                $wInstitution = $value["wInstitution"];
            }
            $this->session->set_userdata("wPower",$wPower);
            $this->session->set_userdata("wName",$wName);
            $this->session->set_userdata("workerId",$workerId);
            $this->session->set_userdata("admin","ok");
            $this->session->set_userdata("wSchool",$wSchool);
            $this->session->set_userdata("wInstitution",$wInstitution);
            redirect("Backend/index/2");
        }
    }

    function login_out()
    {
        session_destroy();   //销毁session
        redirect("Login/index");
    }




}